<?php
declare(strict_types=1);

namespace App\Model;



use Hyperf\Database\Model\Events\Saving;
use Hyperf\Cache\Annotation\Cacheable;
use Hyperf\Database\Model\SoftDeletes;
use League\Flysystem\Filesystem;
use Hyperf\Di\Annotation\Inject;
/**
 * @property $id
 * @property $name
 * @property $created_at
 * @property $updated_at
 */
class ProductLayout extends Model
{
    /**
     * @var Filesystem
     */
    #[Inject]
    private Filesystem $filesystem;
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected? string $table = 'product_layouts';

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected array $fillable = ['id', 'name', 'background', 'thumb', 'preview_thumb', 'area', 'product_id', 'created_at', 'updated_at', 'deleted_at'];
    protected array $hidden = ['created_at', 'updated_at', 'deleted_at'];
    public function getThumbAttribute($value){
        if(empty($value))return '';
        return $this->filesystem->publicUrl($value);
    }

    public function getPreviewThumbAttribute($value){
        if(empty($value))return '';
        return $this->filesystem->publicUrl($value);
    }

    public function getBackgroundAttribute($value){
        if(empty($value))return '';
        return $this->filesystem->publicUrl($value);
    }
}